package com.somta.springboot.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.somta.springboot.dao.master.UserMasterDao;
import com.somta.springboot.dao.slaver.UserSlaverDao;
import com.somta.springboot.pojo.User;

@Service
public class UserService {
	
	@Autowired
	private UserMasterDao userMasterDao;
	
	@Autowired
	private UserSlaverDao userSlaverDao;

	@Transactional(transactionManager = "xatx", propagation = Propagation.REQUIRED, rollbackFor = { java.lang.RuntimeException.class })
	public void addUser() {
		User user = new User();
		user.setName("heloo");
		user.setAge(26);
		userMasterDao.addUser(user);
		System.out.println(1/0);
		userSlaverDao.addUser(user);
		
	}
	

}
